import { isReferee } from "@/func";
import { WereWolfNextTool } from "@/werewolf/components/nextTool";
import { WereWolfDiscussPhase } from "@/werewolf/phases/discuss";
import { WereWolfPhaseView } from "@/werewolf/phaseView";
import { ScriptRunner } from "@sapi-game/Runner/scriptRunner";

export class DiscussClassicView extends WereWolfPhaseView<WereWolfDiscussPhase> {
    override async runPhaseView(r: ScriptRunner): Promise<void> {
        await r.wait(40);
        this.context.players.title("§e§l讨论时间");
        this.context.players.playSound("block.bell.hit");
        this.waitForNext();
    }

    waitForNext() {
        this.state.addComponent(WereWolfNextTool, {
            onUse: () => this.state.next(),
            getPlayers: () =>
                this.context.players.filter(
                    (p) => p.player != undefined && isReferee(p.player)
                ),
        });
        //给裁判物品
        this.state.getComponent(WereWolfNextTool).giveNextItemToReferee();
    }
}
